#include "gwbase/base/logging.h"
#include "gwbase/base/test_harness.h"
#include "gwbase/base/string_util.h"

class LoggingTest {
};

TEST(LoggingTest, WriteLog) {
  LOG_TRACE << 123;
  LOG_DEBUG << 123;
  LOG_INFO << 123;
  LOG_WARN << 123;
  LOG_ERROR << 123;

  SetLogLevel(dicom::kLogWarn);

  LOG_TRACE << 123;
  LOG_DEBUG << 123;
  LOG_INFO << 123;
  LOG_WARN << 123;
  LOG_ERROR << 123;
}

TEST(LoggingTest, RollginFile) {
  std::string msg;
  dicom::StringPrintf(&msg, "%02d--------------", 99);
  SetLogLevel(dicom::kLogInfo);
  dicom:: SetRollingFileLogging("log", "logging_test");
  for (int i = 0; i < 2*1024*1024; ++i) {
    LOG_INFO << msg;
  }
}

int main() {
  dicom::RunAllTests();
  return 0;
}
